<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-date"></i> 刷新cdn</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="plugins-tips">
            刷新act域的cdn地址（阿里云）
        </div>
        <el-form :model="aliForm" :rules="rules" ref="aliForm" label-width="100px" class="demo-ruleForm">
                 <el-form-item label="刷新地址"  prop="desc">
                    <el-input type="textarea" v-model="aliForm.desc" placeholder="act静态资源地址，通过｜分割。"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit(1)">提交</el-button>
                    <el-button>取消</el-button>
                </el-form-item>
            </el-form>
            <div class="plugins-tips">
            刷新static域的cdn地址（帝联）
        </div>
        <el-form :model="dlForm" :rules="rules" ref="dlForm" label-width="100px" class="demo-ruleForm">
                 <el-form-item label="刷新地址"  prop="desc">
                    <el-input type="textarea" v-model="dlForm.desc" placeholder="static静态资源地址，通过｜分割。"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit(2)">提交</el-button>
                    <el-button>取消</el-button>
                </el-form-item>
            </el-form>
    </div>
</template>

<script>
    // import IEcharts from 'vue-echarts-v3';
    export default {
        data: function(){
            return  {
                aliForm:{
                    desc:'',
                },
                rules:{
                    desc:{
                        required:true,
                        message:"请输入正确的cdn地址",
                        trigger:'blur'
                    }
                },
                dlForm:{
                    desc:''
                }
            }
        },
        methods:{
            onSubmit:function(type){
                // console.log(type);
                const self = this;
                if(type == 1){
                    // 这里要做成读配置的。&val=xxx
                    this.$http.get("/cdn/aliRefresh"+"?val="+self.aliForm.desc).then(
                        function (res) {
                            // 处理成功的结果
                            if(res.body.code == 200){
                                self.$message({
                                    message:'刷新cdn成功',
                                    type:'success'
                                });
                            }else{
                                const message ='如下几张图片没有上传成功:'+res.body.err.join(',');
                                self.$message({
                                    message:message,
                                    type:'error',
                                    showClose:true,
                                    duration:'10000'
                                })
                            }
                        },function (res) {
                        // 处理失败的结果
                            console.log(res);
                        }
                    );
                }else if(type == 2){
                    this.$http.get("/cdn/dlRefresh"+"?val="+self.dlForm.desc).then(
                        function (res) {
                            // 处理成功的结果
                            console.log(res.body);
                        },function (res) {
                        // 处理失败的结果
                            console.log(res);
                        }
                    );
                }
            }
        }
    }

</script>

<style scoped>
    /*.mix-echarts{
        width:900px;
        height:600px;
    }*/
</style>